#include <iostream>
using namespace std;

typedef long long LL;

const int N = 1e6 + 10;

int n;
int a[N];
int tmp[N];

LL dfs(int l,int r){
    if(l == r) return 0;
    int mid = (l + r) >> 1;
    LL ret = dfs(l,mid) + dfs(mid+1,r);
    int i = l,j = mid+1,k = l;
    while(i <= mid && j <= r){
        if(a[i] <= a[j]) tmp[k++] = a[i++];
        else {
            ret += mid - i + 1;
            tmp[k++] = a[j++];
        }
    }
    while(i <= mid) tmp[k++] = a[i++];
    while(j <= r) tmp[k++] = a[j++];
    for(int i = l;i <= r;i++){
        a[i] = tmp[i];
    }
    return ret;
}

int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    cout << dfs(1,n) << endl;
    
    return 0;
}
